package com.stone.controller.api;

import com.stone.bean.AppResponse;
import com.stone.bean.BasePage;
import com.stone.entity.TestDO;
import com.stone.service.TestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * api
 */
@Slf4j
@RestController
@RequestMapping("/api")
@Api(tags = "test controller")
public class ApiController {

    @Resource
    private TestService testService;

    @GetMapping("/list/{name}")
    public AppResponse list(@PathVariable("name") String name, HttpServletRequest request, HttpServletResponse response) {
        return testService.findAllByName(name);
    }

    @GetMapping("/list/mapper/{name}")
    public AppResponse list1(@PathVariable("name") String name) {
        return testService.findAll(name);
    }

    @GetMapping("/query")
    @ApiOperation("分页查询")
    public AppResponse<TestDO> query(BasePage dto) {
        return testService.query(dto);
    }

}

